<?php

namespace App\Model;


use Illuminate\Http\Request;

class RedPacketSet extends BaseModel
{
    protected $connection = 'api';
    protected $table = 'red_packet';
    
    public function getList(Request $request){
        $limit = $request->input('limit',10);
        $page = $request->input('page',1);
        $query = new self();
        // todo 搜索
        return $query->orderBy('id','DESC')->paginate($limit,'*','page',$page);
    }
    
    /**
     * 创建红包
     * @param $data
     * @return mixed
     */
    public function createData($data) {
        return curl_request(getKkaudioApiUrl() . '/inner/red/cms/packet/send', $data, 'json', 'POST');
    }
    
    /**
     * 红包开关
     * @param $data
     * @return mixed
     */
    public function switchRed($data) {
        return curl_request(getKkaudioApiUrl() . '/inner/red/packet/setStatus', $data, 'json', 'POST');
    }
    
    /**
     * 红包开关开启状态
     * @return mixed
     */
    public function getSwitchStatus() {
        return curl_request(getKkaudioApiUrl().'/inner/red/packet/status','','urlencoded','GET');
    }
}
